﻿Public Class QLHS

    Private Function CheckExistForm(ByVal name As String) As Boolean
        Dim check As Boolean = False
        'Dim frm As Form

        For Each frm As Form In Me.MdiChildren
            If frm.Name = name Then
                check = True
                Exit For
            End If
        Next

        Return check
    End Function

    Private Sub ActiveChildForm(ByVal name As String)
        For Each frm As Form In Me.MdiChildren
            If frm.Name = name Then
                frm.Activate()
            End If
        Next
    End Sub

    Private Sub mn_TiepNhanHS_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mn_TiepNhanHS.Click
        If CheckExistForm("TiepNhanHS") = False Then
            Dim frm As New TiepNhanHS
            frm.MdiParent = Me

            frm.Show()
        Else
            ActiveChildForm("TiepNhanHS")
        End If

    End Sub

    Private Sub ToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mn_hs.Click

    End Sub

    Private Sub mn_DanhSachLop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mn_DanhSachLop.Click

        If CheckExistForm("LapDSLop") = False Then
            Dim frmlapdslop As New LapDSLop
            frmlapdslop.MdiParent = Me
            frmlapdslop.Show()
        Else
            ActiveChildForm("LapDSLop")
        End If
    End Sub

    Private Sub mn_TraCuuHS_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mn_TraCuuHS.Click

        If CheckExistForm("TraCuuHS") = False Then
            Dim frmTraCuuHS As New TraCuuHS
            frmTraCuuHS.MdiParent = Me
            frmTraCuuHS.Show()
        Else
            ActiveChildForm("TraCuuHS")
        End If
    End Sub

    Private Sub mn_TiepNhanHS_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles mn_TiepNhanHS.MouseDown
        'Cursor =Cursors.Hand 
    End Sub

    Private Sub QLHS_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Dim frmDN As DanhNhap = New DanhNhap()
        'frmDN.Close()
    End Sub

    Private Sub mn_capnhathocsinh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mn_capnhathocsinh.Click

        If CheckExistForm("DanhSachHS") = False Then
            Dim frm As New DanhSachHS
            frm.MdiParent = Me
            frm.Show()
        Else
            ActiveChildForm("DanhSachHS")
        End If
    End Sub

    Private Sub mn_logout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mn_logout.Click
        If MessageBox.Show("Bạn muốn đăng xuất???", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign) = Windows.Forms.DialogResult.Yes Then
            Me.Hide()
            Dim frmDN As New DangNhap
            frmDN.Show()
        End If
    End Sub

    Private Sub MenuStrip1_ItemClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles MenuStrip1.ItemClicked

    End Sub


End Class
